<?php
require_once 'Zend/View/Helper/Abstract.php';

/**
 * The page helper injects a basic page content at the proscribed location. Handy
 * for adding incidental page data.
 * 
 * @author Michael Krotscheck
 */
class Core_View_Helper_Page extends Zend_View_Helper_Abstract
{
	public $pageId;
	
	public $headerTag = 'h2';

	public function page ( $pageId, $headerTag = 'h2' )
	{
		$this->pageId = $pageId;
		$this->headerTag = $headerTag;
		
		return $this;
	}
	
	public function renderExcerpt ( )
	{
		$page = Core_Page::factory($this->pageId);
		
		return sprintf('<%1$s>%2$s</%1$s><p>%3$s</p>', $this->headerTag, $page->title, $page->excerpt );
	}
	
	public function renderPage ( )
	{
		$page = Core_Page::factory($this->pageId);

		$header = sprintf('<%1$s>%2$s</%1$s>', $this->headerTag, $page->title );
		$content = $page->content;
		
		return $header . $content;
	}
}